home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
system
/
abort.zip
/
ABORT.A86
next >
Wrap
Text File
|
1986-03-23
|
6KB
|
244 lines
; ABORT.EXE (updated 02/19/86 by S. Kluger to document change
; required to reassign the abort key (ALT-C by default)).
; The problem is that ^C when used in WordStar sometimes will
; abort to DOS... Use the tech manual to find a new key value
; and stuff it in where marked with [SFK]...
;
; a program to trap the Control-C key and to abort
; the currently resident process (such as the DSI Loader)
; derived from :
; buf128: a 128 character type-ahead buffer for the IBM-PC
; by Trevor Marshall 10/12/85
;
; This program is assembled with DRI's RASMPC.EXE (or with RASM86.CMD under
; CCP/M) and linked with LINK.EXE or LINKPC.EXE.
;
; This program works by intercepting the calls to the BIOS
; interrupt routines at 9 for the keystroke interrupts and
; 16H for the program requests
; Everything is kept in the CS.
;
; NOTE that you should abort a program only if you know exactly what you're
; doing (ie a runaway program just infinite-looped etc). Any open files
; will NOT be closed and you should run CHKDSK /F immediately to clean
; up the file system!
;
cseg
public main_,key_int,request,buffer,head,tail
;
KEYINT equ .24H ; int 9 vector offset
REQINT equ .58H ; int 16H vector offset
B_HEAD equ .1AH ; offset to BUFFER_HEAD
B_TAIL equ .1CH ; offset to BUFFER_TAIL
KB_FLAG equ .17H ; offset to KB_FLAG
main_: jmp init_code
;
buffer dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
head dw buffer
tail dw buffer
ax_save dw 0
bx_save dw 0
code_seg dw 0
;
; the keystroke interrupt routine. Interrcept the key interrupt, run
; it through the standard key input routine, and remove it from the buffer.
;
key_int:
cli
;Find out where we are coming from
mov WORD PTR ax_save,ax ;save AX a while
mov WORD PTR bx_save,bx ;save BX a while
pop ax ;reurn address into AX
pop bx ;now have calling code segment in BX
push bx ;restore the stack
push ax
mov WORD PTR code_seg,bx ;save it for later
mov ax,WORD PTR ax_save ;restore AX
mov bx,WORD PTR bx_save ;restore BX
;begin the handler
pushf ; simulate an interrupt on return
;
; long call to F000:E987
; (this poses a problem with non-compatible BIOSes such as the one
; found in the latest Leading Edge model M, but should work in
; most clones. [sfk]
;
db 9AH
dw 0E987H
dw 0F000H
;
push bx
push es
push ax
mov bx,40H ; BIOS data segment
mov es,bx
mov bx, es:WORD PTR B_HEAD ; pointer to datum
cmp bx, es:WORD PTR B_TAIL ; test for character
je k_esbx ;return if none
mov es:WORD PTR B_TAIL, bx ; clear the buffer
mov bx, es:[bx] ;get the char to bx
;
mov ax,bx ;get char to ax
;
; [SFK]
; the following line for use with "normal" key codes:
; replace the "3" with whatever key scan code you wish to
; use as the ABORT key (CTRL-D = 4 etc).
; cmp al,3 ;ready to see if its a control-c
;
; [SFK]
; comment out the cmp above and enable the following line if an EXTENDED
; key is to be the ABORT key, such as ALT-X, CTRL-F10, or whatever.
; Note: the scan code must be in hex, and must be contained in the
; upper byte of the compare word as shown in the example. The low
; byte must be 00!
cmp ax,2E00H ; test for abort key (ALT-C)
;
jne no_abort ;if not then continue
;Before aborting we must check that DOS itself is not the current process.
; We can do this by checking that the calling code segment is higher than
; the segment at which this driver was loaded
mov ax,WORD PTR code_seg
db 3dh ;CMP AX,
POKE1 dw 0 ;overwritten by initializer code
jb no_abort ;if current CS is below us then dont abort
;Also check that we are not executing the BIOS ROM
cmp ax,0af00h
jnb no_abort
pop ax
pop es
pop bx
;issue a non-specific EOI to the 8259
mov al,20h
out 20h,al
;issue a specific EOI to the floppies
; mov al,26h
; out 20h,al
;issue a specific EOI to the fixed disk
; mov al,25h
; out 20h,al
;
mov ah,4ch
mov al,0 ;no errors to report
sti ;all ok again for interrupts now
int 21h
no_abort:
;
push si
mov si, cs:tail
push si ; save tail value
add si,2 ; test for full
cmp si, offset buffer+256
jb k_over1
mov si, offset buffer
k_over1:
cmp si, cs:head
pop si
je k_siesbx ; jump if buffer full
mov cs:[si], bx ; store the character
add si,2
cmp si, offset buffer+256
jb k_over2
mov si, offset buffer ;wrap around
k_over2:
mov cs:tail, si
k_siesbx:
pop si
k_esbx:
pop ax
pop es ; no character, return
pop bx
iret
;
; The request interrupt routine.
;
; simulate the BIOS routine
; ah = 0 read next char
; ah = 1 set Z flag on character status, ZF=1 if no char
; ZF=0 and AX = char if char ready
; ah = 2 shift status
request:
sti
or ah,ah
jz do_read
dec ah
jz do_stat
dec ah
jz do_shift
iret
do_read: ; return the next character
sti
nop
cli
mov ax,cs:head
cmp ax,cs:tail
je do_read ; loop until a character
push bx
mov bx,ax
mov ax, cs:[bx] ; ax gets the character
add bx,2
cmp bx, offset buffer+256
jb r_over
mov bx, offset buffer
r_over:
cmp bx, cs:tail
mov cs:head, bx ; new head
pop bx
iret
do_stat: ; return key status
cli
push bx
mov bx,cs:head
cmp bx,cs:tail
mov ax,cs:[bx]
pop bx
sti
retf 2 ; throw out the flags
do_shift:
push es
mov ax,40H ; BIOS data segment
mov es,ax
mov al, es:byte ptr KB_FLAG
pop es
iret
init_code: cli ; turn off interrupts for now
mov ax,0
mov es,ax ; segment base for vectors
mov es:WORD PTR KEYINT, offset key_int
mov es:WORD PTR KEYINT+2, cs
mov es:WORD PTR REQINT, offset request
mov es:WORD PTR REQINT+2, cs
mov cs:head, offset buffer
mov cs:tail, offset buffer
; Code added 10/12/85 by TM to calculate the current CS value and poke it into
; the location in the interrupt handler which checks that DOS is not the
; current task
mov cs:WORD PTR poke1, cs
;
sti
mov ds:byte ptr .1, 27H ; change PCB terminate to resident
push ds
mov dx,0
push dx
mov dx, offset init_code+100H
retf ; long return to the int 27H
end